/**
 * Note: The returned array must be malloced, assume caller calls free().
 */
char ** buildArray(int* target, int targetSize, int n, int* returnSize){
    char** ans = (char**)malloc(sizeof(char*)*(2*n));
    *returnSize = 0;
    int i = 0;
    int num = 1;
    while (num <= target[targetSize-1])
    {
        if (target[i] == num)
        {
            ans[(*returnSize)] = (char*)malloc(sizeof(char)*5);
            memcpy(ans[(*returnSize)],"Push",5);
            (*returnSize)++;
            i++;
            num++;            
        }
        else
        {
            while (num < target[i])
            {
                num++;  
                ans[(*returnSize)] = (char*)malloc(sizeof(char)*5);
                memcpy(ans[(*returnSize)],"Push",5);
                (*returnSize)++;    

                ans[(*returnSize)] = (char*)malloc(sizeof(char)*4);
                memcpy(ans[(*returnSize)],"Pop",4);
                (*returnSize)++;                          
            }
        }
    }
    return ans;
}